<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use backend\models\User;

use backend\models\GoodsClass;
/* @var $this yii\web\View */
/* @var $model backend\models\Goods */

$this->title = $model->goodsname;
$this->params['breadcrumbs'][] = ['label' => '商品列表', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;


$goodsclass = new GoodsClass();
$goodsclass_1 = $goodsclass->findOne($model->class);

$model->class = $goodsclass_1->classname;
$com=$model->upfee<=>0 ;
if($com>0){
    $model->upfee='+'.$model->upfee.'%';
}elseif($com==0){
$model->upfee='0%';
}else{
    $model->upfee=$model->upfee.'%';
}

if($model->check==0){
    $model->check='待审核';
}elseif($model->check==1){
    $model->check='一审通过';
}elseif($model->check==2){
    $model->check='二审通过';
}elseif($model->check==3){
    $model->check='审核通过';
}elseif($model->check==4){
    $model->check='不通过';
}

?>
<div class="goods-view">

    <h1><?= Html::encode($this->title) ?></h1>
<?php if($model->check==3 || $model->check==4){?>
    <p>
        <?= Html::a('更新', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>

    </p>
    <?php }?>
    <?php if(!empty(Yii::$app->session['send_info'])){?>
        <p>
            <?=Yii::$app->session['send_info']; ?>
        </p>
    <?php
    unset(Yii::$app->session['send_info']);
    }?>

    <?= DetailView::widget([
        'model' => $model,
        'attributes' => [
            'id',
            'goodsid',
            'goodsno',
           ['attribute'=>'gys','value'=>function($model){
                $gys=User::findOne($model->gys);
                return !empty($gys) ? $gys->realname : '未分配';
           }],
            'goodsname',
            'class',

            ['attribute'=>'inprice','value'=>function($model){
                if($model->priceunit){
                    $unit="$";
                }else{
                    $unit="￥";
                }
                return $unit.$model->inprice;
            }],
            ['attribute'=>'lastprice','value'=>function($model){
                if($model->priceunit){
                    $unit="$";
                }else{
                    $unit="￥";
                }
                return $unit.$model->lastprice;
            }],

            'upfee',
            'remark:ntext',
            'check',

           ['label'=>'运营商','value'=>function($model){
               $yys=User::findOne($model->nextid);
               return !empty($yys) ? $yys->realname : '未分配';
           }] , 'createtime',
            'updatetime',
        ],
    ]) ?>

</div>
